package com.monitor.action.user;

import java.io.PrintWriter;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.CallLog;
import com.monitor.service.CallLogService;
import com.monitor.util.Constants;
import com.monitor.util.Pager;

public class CallLogAction extends MonitorActionSupport {

	private static final long serialVersionUID = 4529666116748945887L;
	private long uid;
	private CallLogService callLogService;
	private int cPage;
	private Pager<CallLog> callLogs;
	private int cid;
	private String cidStr;

	@Override
	public String execute() throws Exception {
		cPage = cPage < 1 ? 1 : cPage;
		callLogs = callLogService.getCallLogByUid(uid, Constants.DEFAULT_PAGESIEZE, cPage);
		return SUCCESS;
	}

	public void deleteCalllog() throws Exception {
		PrintWriter out = getWriter();
		boolean success = callLogService.deleteCalllog(uid, cid);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public void deleteMultiCalllog() throws Exception {
		PrintWriter out = getWriter();
		boolean success = callLogService.deleteCalllog(uid, cidStr);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public CallLogService getCallLogService() {
		return callLogService;
	}

	public void setCallLogService(CallLogService callLogService) {
		this.callLogService = callLogService;
	}

	public int getcPage() {
		return cPage;
	}

	public void setcPage(int cPage) {
		this.cPage = cPage;
	}

	public Pager<CallLog> getCallLogs() {
		return callLogs;
	}

	public void setCallLogs(Pager<CallLog> callLogs) {
		this.callLogs = callLogs;
	}

	public int getCid() {
		return cid;
	}

	public void setCid(int cid) {
		this.cid = cid;
	}

	public String getCidStr() {
		return cidStr;
	}

	public void setCidStr(String cidStr) {
		this.cidStr = cidStr;
	}

}
